<template>
  <page-meta :root-font-size="fontsize" style="display: block">
    <div class="page regulateResume">
      <xlNavBar :isShare="isShare" title="管理求职需求" bgc="ff9d49" :showLeft="true"></xlNavBar>
      <div class="container">
        <regulateResumeItem v-for="item in myList" :key="item.id" :item="item" @update="getList"></regulateResumeItem>
      </div>

      <div class="bottom_jj" v-if="!myList[0].is_buy_urgent">
        <div class="title">求职加急，求职快人一步</div>
        <div class="s_title">加急求职，找工作快三倍，求职曝光度多两倍！</div>
        <div class="images_wrap">
          <image src="@/pages2/static/images/1.png" mode="scaleToFill" />
          <image src="@/pages2/static/images/2.png" mode="scaleToFill" />
          <image src="@/pages2/static/images/3.png" mode="scaleToFill" />
        </div>
        <div class="btn" @click="tojjqz">加急求职</div>
      </div>
      <footer class="footer" v-if="myList[0].status === 1">
        <div class="left">刷新求职发布时间，提高名片排名让 更多老板联系您</div>
        <div class="right_btn" @click="refresh">1积分刷新</div>
      </footer>
    </div>
    <contact-popup
      @submit="goChonzhi"
      :show="showContactPopup"
      @close="showContactPopup = false"
      title="温馨提示"
      content="当前您的积分不足，是否前往获取积分？"
      btnTetx="去获取积分"
    ></contact-popup>
  </page-meta>
</template>

<script>
import regulateResumeItem from "@/pages2/components/resume/regulateResumeItem.vue";
import ContactPopup from "./components/popup/contactPopup.vue";
export default {
  name: "regulateResume",
  components: { regulateResumeItem, ContactPopup },
  props: {},
  data() {
    return {
      showContactPopup: false,
      fontsize: "",
      code: "",
      isShare: 0,
      myList: [],
      share: {
        title: "求职详情",
        path: "/pages2/resumeDetail?share=1",
        imageUrl: "https://chenxiao.obs.cn-north-1.myhuaweicloud.com/img/46_1682130751448648175.QVDVzWp4c2Npdf593bd7f86a5d375e51ec99811cef26.jpg",
        desc: "",
        content: "",
      },
    };
  },
  methods: {
    goChonzhi() {
      this.showContactPopup = false;
      this.$togo("/pages3/integralRechargePage");
    },
    async getList() {
      let res = await this.$http.requestSync("/resumes/my", {}, "GET");
      if (res.code == 200) {
        this.myList = res.resumes;
        let resume = res.resumes[0];
        this.share.path = `/pages2/resumeDetail?share=1&params=${JSON.stringify(resume)}&id=${resume.id}`;
        this.share.title = "求职：" + resume["job_intention"].split(",").join(" ") || resume["job_intention"];
        this.share.imageUrl = await this.$drawPoster(
          {
            type: "求职",
            tag: resume.job_intention.split(",") || [resume.job_intention],
            desc: resume.content || "",
            address: resume.city_list.split(",").join(" ") || resume.city_list,
          },
          this
        );
      }
    },
    addUrgent() {
      this.$togo("/pages2/postRecruitmentInformation");
    },
    async refresh() {
      if (this.myList.length === 0) {
        return;
      }
      let params = {
        id: this.myList[0].id,
        integral: 1,
      };
      console.log(111, params);
      let res = await this.$http.requestSync("/resumes/refresh", params);
      console.log(res);
      try {
        if (res.code == 200) {
          this.getList();
          this.$layer.message("刷新成功");
        } else {
          this.showContactPopup = true;
        }
      } catch (error) {
        this.showContactPopup = true;
      }
    },
    tojjqz() {
      this.$togo("/pages2/urgentResume", {
        id: this.myList[0].id,
        from: "list",
      });
    },
  },
  // 页面周期函数--监听页面加载
  onShow(options) {
    if (options && options.params) {
      let params = JSON.parse(decodeURIComponent(options.params));
      if (params.shareUserId) {
        this.$setStoraged("shareUserId", params.shareUserId);
        this.isShare = 1;
      }
    }
    this.getList();
    let designWidth = 37.5; //因设计图的宽度
    let that = this;
    //窗体改变大小触发事件
    uni.onWindowResize(res => {
      console.log("变化后的窗口宽度=", res.size.windowWidth);
      //100*屏幕宽度/设计稿宽度
      that.fontsize = Math.floor((1.5 * res.size.windowWidth) / designWidth) + "px";
      console.log("字体大小：", that.fontsize);
    });

    //打开获取屏幕大小
    uni.getSystemInfo({
      success(res) {
        console.log("设备信息：", res);
        that.fontsize = Math.floor((1.5 * res.screenWidth) / designWidth) + "px";
        console.log("字体大小：", that.fontsize);
      },
    });
  },
  // 页面周期函数--监听页面初次渲染完成
  onReady() {},
  // 页面周期函数--监听页面隐藏
  onHide() {},
  // 页面周期函数--监听页面卸载
  onUnload() {},
  // 页面处理函数--监听用户下拉动作
  // onPullDownRefresh() { uni.stopPullDownRefresh(); },
  // 页面处理函数--监听用户上拉触底
  // onReachBottom() {},
  // 页面处理函数--监听页面滚动(not-nvue)
  // onPageScroll(event) {},
  // 页面处理函数--用户点击右上角分享
  // onShareAppMessage(options) {},
};
</script>

<style scoped lang="scss">
.regulateResume {
  height: 100vh;
  background: #f7f7f7;
  box-sizing: border-box;
  display: table;
  .container {
    background: #fff;
    box-sizing: border-box;
    padding: 10px;
  }
  .add-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 44px;
    line-height: 44px;
    background: #ffffff;
    border-radius: 8px;
    padding: 0 10px;
    margin: 0 10px;
    margin-top: 10px;
    .left {
      display: flex;
      align-items: center;
      .add {
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        width: 20px;
        height: 20px;
        border-radius: 10px;
        background: #ff8822;
        color: #ffffff;
        font-weight: 600;
      }
      .info {
        margin-left: 4px;
        color: #333333;
        font-weight: 600;
      }
    }
    .right {
      display: flex;
      align-items: center;
      .info {
        font-size: 12px;
        color: #999999;
      }
      .icon {
        margin-right: 6px;
        width: 16px;
        height: 16px;
      }
    }
  }
  .bottom_jj {
    width: 95%;
    background: #ffffff;
    border-radius: 10px 10px 10px 10px;
    margin: 10px auto;
    box-sizing: border-box;
    padding: 10px;
    .title {
      width: 100%;
      height: 42px;
      line-height: 32px;
      border-bottom: 1px solid #e4e4e4;
      font-size: 16px;
      font-family: PingFang SC-Semibold, PingFang SC;
      font-weight: 600;
      color: #333333;
    }
    .s_title {
      font-size: 13px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      margin: 10px auto 15px;
    }
    .images_wrap {
      display: flex;
      justify-content: space-around;
      image {
        width: 103px;
        height: 103px;
      }
    }
    .btn {
      width: 245px;
      height: 40px;
      background: linear-gradient(90deg, #ffa222 0%, #ff8822 100%);
      border-radius: 20px 20px 20px 20px;
      font-size: 16px;
      font-family: PingFang SC-Semibold, PingFang SC;
      font-weight: 600;
      color: #ffffff;
      text-align: center;
      line-height: 40px;
      margin: 20px auto;
    }
  }
  .footer {
    width: 100%;
    height: 79px;
    background: #fff;
    position: fixed;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 0 10px;
    .left {
      width: 192px;
      font-size: 12px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
    }
    .right_btn {
      width: 138px;
      height: 42px;
      background: linear-gradient(122deg, #ffa222 0%, #ff8822 100%);
      border-radius: 21px 21px 21px 21px;
      text-align: center;
      line-height: 42px;
      color: #fff;
    }
  }
}
</style>
